﻿// Decompiled with JetBrains decompiler
// Type: Netick.DirectAllocator
// Assembly: Netick, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: 6726ECA1-C773-4CF7-8952-E81B30D93B52
// Assembly location: D:\WorkSpaceDemo\UPM\NetickForUnity\Netick\Runtime\Netick.dll
// XML documentation location: D:\WorkSpaceDemo\UPM\NetickForUnity\Netick\Runtime\Netick.xml

#nullable disable
namespace Netick;

internal class DirectAllocator : IAllocator
{
  internal static DirectAllocator Instance = new DirectAllocator();

  public unsafe void* Allocate(ulong sizeBytes, out int poolIndex, out long offset, bool clearMem)
  {
    void* ptr = MemoryAllocation.Malloc((long) sizeBytes);
    if (clearMem)
      MemoryAllocation.Clear(ptr, (long) sizeBytes);
    poolIndex = 0;
    offset = 0L;
    return ptr;
  }

  public unsafe void Deallocate(void* ptr) => MemoryAllocation.Free(ptr);
}
